// Bench.h

#ifndef __7ZIP_BENCH_H
#define __7ZIP_BENCH_H

#include "Common/7Zip/CreateCoder.h"

namespace Extract
{

struct CBenchInfo
{
  UINT64 GlobalTime;
  UINT64 GlobalFreq;
  UINT64 UserTime;
  UINT64 UserFreq;
  UINT64 UnpackSize;
  UINT64 PackSize;
  UINT32 NumIterations;
  CBenchInfo(): NumIterations(0) {}
};

struct IBenchCallback
{
  virtual HRESULT SetEncodeResult(const CBenchInfo &info, bool final) = 0;
  virtual HRESULT SetDecodeResult(const CBenchInfo &info, bool final) = 0;
};

UINT64 GetUsage(const CBenchInfo &benchOnfo);
UINT64 GetRatingPerUsage(const CBenchInfo &info, UINT64 rating);
UINT64 GetCompressRating(UINT32 dictionarySize, UINT64 elapsedTime, UINT64 freq, UINT64 size);
UINT64 GetDecompressRating(UINT64 elapsedTime, UINT64 freq, UINT64 outSize, UINT64 inSize, UINT32 numIterations);

HRESULT LzmaBench(
  DECL_EXTERNAL_CODECS_LOC_VARS
  UINT32 numThreads, UINT32 dictionarySize, IBenchCallback *callback);

const int kBenchMinDicLogSize = 18;

UINT64 GetBenchMemoryUsage(UINT32 numThreads, UINT32 dictionary);

bool CrcInternalTest();
HRESULT CrcBench(UINT32 numThreads, UINT32 bufferSize, UINT64 &speed);

}
#endif
